package org.feng.common;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 请求响应参数保持类
 *
 * @author fengjinsong
 */
public final class RequestHolder {

    /**
     * 当前请求线程的request对象
     */
    public final static ThreadLocal<HttpServletRequest> REQUEST_LOCAL = new InheritableThreadLocal<>();

    /**
     * 当前请求线程的response对象
     */
    public final static ThreadLocal<HttpServletResponse> RESPONSE_LOCAL = new InheritableThreadLocal<>();

    /**
     * 用户信息-每次请求头中的参数
     */
    public final static ThreadLocal<RequestHeaderUserInfo> REQUEST_HEADER_USER_INFO_THREAD_LOCAL = new InheritableThreadLocal<>();


    /**
     * 清空 threadlocal
     */
    public static void remove() {
        REQUEST_LOCAL.remove();
        RESPONSE_LOCAL.remove();
        REQUEST_HEADER_USER_INFO_THREAD_LOCAL.remove();
    }
}
